package com.lovo.csc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.csc.bean.TenderVendorBean;
import com.lovo.csc.service.ITenderService;
import com.lovo.csc.service.ITenderVendorService;
import com.lovo.csc.service.IVendorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("tv")
public class TenderVendorController {

    @Autowired
    ITenderVendorService tenderVendorService;
    @Autowired
    IVendorService vendorService;


    @GetMapping("findByTId/{tid}/{status}/{pageNO}")
    public IPage<TenderVendorBean> findByTId(@PathVariable("tid") String tid, @PathVariable("status") int status, @PathVariable("pageNO") Integer pageNO){
        return tenderVendorService.findByTId(tid, status, pageNO);
    }
    @GetMapping("updateStatus/{id}/{status}/{vendorName}")
    public String updateStatus(@PathVariable("id") long id,@PathVariable("status") int status,@PathVariable("vendorName") String vendorName){
        tenderVendorService.updateStatus(id, status,vendorName);
        return "ok";
    }

    @RequestMapping("updateTenderVendor")
    public boolean updateTenderVendor(@RequestParam("vendorName") String vendorName,@RequestParam("tenderIdNum") String tenderIdNum,@RequestParam("url") String url){
        vendorService.updateTenderVendor(vendorName, tenderIdNum, url);
        return true;
    }

    @PostMapping("addtv")
    public String addtenderVendor(Long idNum,Long[] newSupper){
        tenderVendorService.addtenderVendor( idNum, newSupper);
        return "ok";
    }
}
